<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

	<meta name="renderer" content="webkit">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>风险防控</title>

    <!-- Bootstrap -->
    <link href="../../css/bootstrap/bootstrap.min.css" rel="stylesheet">
	<link href="../../css/bootstrap/customOA.css" rel="stylesheet">
	<link href="../../css/site/page.css" rel="stylesheet" type="text/css" />
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <script src="../../js/require.js"></script>
    <!--[if lt IE 9]>
    	 <script>
			require(['../../js/appConf'], function() {
			    require(['jquery','html5shiv','respond'], function() {
					
			    });
			});
		</script>      
    <![endif]-->
  </head>
  <body>
 <div id="download-related-file" class="container">
		<div class="row">
			
			
	        
	        
	        <div class="table-responsive">
            	<table class="table table-striped dg-list">
            		<thead>
		                <tr>		                  
		                  <th class="col-md-2">软件序号</th>
		                  <th class="col-md-10 placeholder">软件名称</th>		                  
		                </tr>
              		</thead>
              		
              		<tbody>
              		</tbody>
            	</table>
            </div>
	</div>	
	<div class="pagination" style="float:right;margin:0px;padding:0px"></div>
</div>


<script type="text/javascript" src="../../js/require.js"></script>
<script type="text/javascript">
require(['../../js/appConf','../../js/sysman'], function() {
    require(['sysmanMain','domReady!'], function(main,doc) {
		var _url = '/portal/getExternalFileList';
		
		var rootid = 'download-related-file';
		var funcDef = {
				
			/*
			* 初始化列表
			*
			*/
			initList:function(data){
				if(data && data.length>0){
					var _html = ''; 
					
					$.each(data,function(i,o){
						_html +='<tr class="file-row">'+
								'<th class="col-md-2">'+i +'</th>'+
		                  		'<th class="col-md-10 placeholder">'+
		                  			'<a class="js-file-name" href="javascript:void(0);" onclick="return false;">'+o.name+'</a>'+
		                  		'</th>'+
		                  		'</tr>';
					})
					
					var _container = $('#' +rootid + ' tbody' )
					if(_container.length==1){
						_container.append(_html);
					}
					
					var btn = $('#'+rootid + ' a.js-file-name')
					if(btn.length>0){
						btn.unbind('click');
						btn.bind('click',funcDef.gridClick)
					}
				}
			}
			,
			//列表行点击函数
			gridClick:function(e){
				var _text;
				if(e){				
					_text = e.currentTarget.text
					if((_text==null)||($.trim(_text).length<=0)){
						if(e.currentTarget.innerText){						
							_text = e.currentTarget.innerText
						}
						
					}
				}
				
				if(_text){
					funcDef.downloadfile(_text);
				}
			}
			,
			downloadfile:function(fileName){
				if(window.console){
					console.log('download file fired ')	
				}
				var _url = '/portal/getExternalFile'
				var form = $("<form>");
				form.attr('style','display:none');
				form.attr('target','');
				form.attr('method','post');
				form.attr('action',_url);
				var input1 = $("<input>");
				input1.attr('type','hidden')
				input1.attr('name','fileName')
				input1.attr('value',encodeURI(fileName));
				$('body').append(form);
				$(form).append(input1);
				
				form.submit();
				form.remove();
				
			}
		}
		$.ajax({
			
			url:_url,
			success:funcDef.initList,
			failure:function(){
				
			}
		})
    });    
});
</script>

</body>
</html>